{extends 'admin/layout/main.tpl'}

{block title}用户管理{/block}
{block smallTitle}系统内用户管理。{/block}

{block breadcrumb}
<li>用户管理</li>
<li><a href="{route('AdminMemberList')}">用户列表</a></li>
{/block}

{block main}
<div class="row">
	<div class="col-lg-12">
		<section class="panel">
			<header class="panel-heading">
				用户列表
            </header>
			<form method="get" action="">
				<span>名称：</span><input type="text" name="nickname" value="{$get.nickname}"/>&nbsp;&nbsp;
				<span>手机：</span><input type="text" name="mobile" value="{$get.mobile}"/>&nbsp;&nbsp;
				<input type="submit" value="搜索">
			</form>
			<br>
			<a class="btn btn-info btn-xs" href="javascript:;" onclick="post(1) "><i class="fa fa-edit"></i> 允许登陆</a>
			<a class="btn btn-info btn-xs" href="javascript:;" onclick="post(2) "><i class="fa fa-edit"></i> 禁止登陆</a>
			<table class="table table-striped table-hover">
				<thead>
					<tr>
						<th><input type=checkbox onclick=sel(this)>&nbsp&nbsp#</th>
						<th>头像</th>
						<th>会员名称</th>
						<th>手机号</th>
						<th>订单数</th>
						<th>成交额</th>
						<th>状态</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
				{foreach $data as $item}
					<tr >
						<td><input name="m" type=checkbox value="{$item.id}">&nbsp&nbsp{$item.id}</td>
						<td>{if $item.avatar_id}<img src="{$item.avatar.url}&width=50">{else}<img style="height: 50px" src="{asset('admin/img/avatar.jpg')}">{/if}</td>
						<td>{$item.nickname|default:'--'|escape}</td>
                        <td>{$item.mobile}</td>
						<td><input value="{$item.ApplyFalseData.applys_num}" type="text" class="applys_num" data-id="{$item.id}"/></td>
						<td><input value="{$item.ApplyFalseData.apply_amount}" type="text" class="apply_amount" data-id="{$item.id}"/></td>
						<td>{$status[$item.status]}</td>
						<td>
                            <a class="btn btn-info btn-xs" href="{route('AdminMemberEdit',['id'=>$item.id])}"><i class="fa fa-edit"></i> 信息</a>
							{*<button class="btn btn-xs btn-danger " type="button" data-role="delete"><i class="fa fa-trash-o"></i> 删除</button>*}
						</td>
					</tr>
				{/foreach}
				</tbody>
			</table>
			{include 'admin/layout/paginate.tpl'}
		</section>
	</div>
</div>
{/block}
{block script}
	<script>
		function sel(o)
		{
			var a = document.getElementsByName("m");
			for (var i=0;i<a.length;i++){
				a[i].checked = o.checked;
			}
		}

		function post(e){
			var compatibility = "",
					input = document.getElementsByName("m"),
					value;
			for (var i = 0; i < input.length; i++) {
				if (input[i].type == "checkbox") {
					if (input[i].checked) {
						value = input[i].value;
						compatibility += value + ",";
					}
				}
			}
			var data = { };
			data.from = 'member';
			data.ids = compatibility;
			data.type = e;
			iconfirm({
				action	: '{route('AdminGlobalInfoEdit')}',
				body		: '确定要执行此操作吗？',
				data		: data
			});
			return false;
		}

		$('.applys_num').blur(function(){
			$.ajax({
				type        : 'POST',
				url         : '{route('AdminGlobalInfoEdit')}',
				data        : 'type=5&ids='+$(this).attr('data-id')+'&data='+$(this).val()+'&from=member',
				dataType	: 'json',
				success     : function(result){
					alert(result.message);
				}
			});
		});
		$('.apply_amount').blur(function(){
			$.ajax({
				type        : 'POST',
				url         : '{route('AdminGlobalInfoEdit')}',
				data        : 'type=6&ids='+$(this).attr('data-id')+'&data='+$(this).val()+'&from=member',
				dataType	: 'json',
				success     : function(result){
					alert(result.message);
				}
			});
		});
	</script>
{/block}
